package com.cy.pj.common.pojo;

import lombok.Data;

import java.io.Serializable;

/**
 * @author Cx
 * @stage secondStageOfWeb
 * @creat 2020-11-13 16:58
 * 借助此对象封装控制层响应到客户端的数据
 */
@Data
public class JsonResult implements Serializable {

    private static final long serialVersionUID = -4971076199594828397L;

    private Integer state = 1; /* 响应状态码 1==ok 0==error */
    private String message = "OK"; /* 响应具体信息 */
    private Object data; /* 响应数据 (一般是查询时获取到的正确数据) */

    public JsonResult() {
    }

    public JsonResult(String message) {
        this.message = message;
    }

    public JsonResult(Object data) {
        this.data = data;
    }

    public JsonResult(Throwable e) {
        this.state = 0;
        this.message = e.getMessage();
    }

}
